<template>
  <tm-app ref="app">
    <!-- #ifndef H5 -->
    <breadCrumb :dataList="data.titleArray"></breadCrumb>
    <!-- #endif -->
    <personList :setList="data.listInfo" @btnClick="goMenu"></personList>
  </tm-app>
</template>

<script lang="ts" setup>
import { memberListData } from '../../relation/config/config'
import personList from '../../relation/components/personList.vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { reactive } from 'vue'
import breadCrumb from '../../../components/breadCrumb/index.vue'
const data = reactive<any>({
  listInfo: [],
  queryItem: {},
  titleArray: []
})
onShow(() => {
  const pages = getCurrentPages()
  let titleArray: any = [] //标题数据
  pages.forEach((_item, index) => {
    if (index > 0) {
      const currentPage: any = pages[pages.length - index]
      const options = currentPage.options
      let data: any = JSON.parse(options.item)
      let jsons: any = {}
      jsons = {
        name: data.label
      }
      titleArray.push(jsons)
    }
  })
  data.titleArray = titleArray.reverse()
})
onLoad(query => {
  if (query && query.item) {
    let item = JSON.parse(query.item)
    data.queryItem = item
    let arr: {
      id: any
      label: any
      itemType: any
      icon: any
      isShow: boolean
    }[] = []
    memberListData.forEach(element => {
      element.itemType = item.itemType
      arr.push(element)
    })
    data.listInfo = arr
  }
})
function goMenu(item: {
  id: any
  label: any
  key: any
  icon: any
  itemType: any
}) {
  const params = {
    key: data.queryItem.key,
    title: data.queryItem.label,
    label: item.label,
    icon: '',
    itemType: item.itemType
  }
  if (item.id === 'member') {
    //个人
    uni.navigateTo({
      url: '/pages/relation-pages/member/memberList?item=' + JSON.stringify(params)
    })
  } else {
    //群组
    uni.navigateTo({
      url: '/pages/relation-pages/group/groupIndex?item=' + JSON.stringify(params)
    })
  }
}
</script>

<style scoped></style>
